package com.hnichr.ump.api.controller;


import com.hnichr.ump.common.assessment.service.AssessmentService;
import com.hnichr.ump.common.assessment.vo.ActivityVO;
import com.hnichr.ump.common.assessment.vo.SubmitAnswerVO;
import com.hnichr.ump.common.assessment.vo.TesteeRegisterResultVO;
import com.hnichr.ump.common.assessment.vo.TesteeRegisterVO;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.mxpioframework.common.vo.Result;

import java.util.List;

@Tag(name = "AssessmentController", description = "测评")
@RestController
@RequestMapping("/api/assessment/v1")
public class AssessmentController {

    @Autowired
    private AssessmentService assessmentService;


    /*@GetMapping("activity")
    @Deprecated
    public Result<List<ActivityVO>> activityList(){
        return Result.OK(assessmentService.listVO());
    }*/

    @GetMapping("activity/{tenantId}")
    public Result<List<ActivityVO>> activityList(@PathVariable  String tenantId){
        if(StringUtils.isBlank(tenantId)){
            return Result.error("没有租户信息");
        }
        return Result.OK(assessmentService.listVO(tenantId));
    }

    @PostMapping("register")
    public Result<TesteeRegisterResultVO> register(@RequestBody TesteeRegisterVO vo){
        return Result.OK(assessmentService.register(vo));
    }


    @PostMapping("submitAnswer")
    public Result<String> submitAnswer(@RequestBody SubmitAnswerVO vo){
        assessmentService.submitAnswer(vo);
        return Result.OK();
    }


}
